using System;
using System.Configuration;
using System.IO;
using System.Net;

namespace resharperupdate.core.services.impl
{
    public class Downloader : IDownloader{
        public string nightly_html()
        {
            var result = "";
            var request = WebRequest.Create(ConfigurationManager.AppSettings["url"]);
            var response = request.GetResponse();
            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                result = sr.ReadToEnd();
                sr.Close();
            }
            return result;
        }

        public string install(string url)
        {
            var temp_file = Path.GetTempFileName() + ".msi";
            using (var wc = new WebClient())
            {
                wc.DownloadFile(url, temp_file);
            }
            return temp_file;
        }
    }
}